import { bannerList } from '../../../request/api'

interface StateBanner {
    bannerlist: Array<object>
}

const state = {
    bannerlist: []
}

const getters = {
    getBannerList(state: StateBanner) {
        return state.bannerlist
    }
}

const mutations = {
    REQ_BANNER(state: StateBanner, payload: any) {
        state.bannerlist = payload
    }
}

const actions = {
    getBannerListAction(context: any) {
        bannerList().then(res => {
            console.log(res);
            if (res.code == 200) {
                console.log(res, '轮播图列表');
                context.commit('REQ_BANNER', res.list)
            }
        })
    }
}

export default {
    state,
    getters,
    actions,
    mutations,
    namespaced: true
} 